<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<div class="pageContent">
	<form method="post" action="./changePassword.action" class="pageForm" onsubmit="return navTabSearch(this);">
		<div class="pageFormContent" layoutH="58">
			<div class="unit">
				<label>用户名：</label>
				<input type="text" size="25" name="username" id="username" readonly="readonly" />
			</div>
			<div class="unit">
				<label>旧密码：</label>
				<input type="password" id="oldPassword" class="required " alt="请输入旧密码" size="25" name="oldPassword"/>
			</div>
			<div class="unit">
				<label>新密码：</label>
				<input type="password" class="required " alt="请输入新密码" size="25" name="newPassword1" id="newPassword1" />
			</div>
			<div class="unit">
				<label>新密码确认：</label>
				<input type="password" class="required " alt="请输入新密码" size="25" name="newPassword2" id="newPassword2" />
			</div>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="button" onclick="changepwd()">提交</button></div></div></li>
				<li><div class="buttonActive"><div class="buttonContent"><button type="button" target="javascript:;" onclick="clearinput()">清空</button></div></div></li>
			</ul>
		</div>
	</form>
<script type="text/javascript">
		$("body").ready(function(){
			var usercode = $.cookie('currentusercode');
			$('#username').val(usercode);
		});
function clearinput()
{
	$('#oldPassword').val('');	
	$('#newPassword1').val('');	
	$('#newPassword2').val('');	
}		
function changepwd()
{
	if($('#oldPassword').val()=='')
	{
		alertMsg.error('请输入密码！');　
		return ;
	}
	if($('#newPassword1').val()=='')
	{
		alertMsg.error('请输入新密码！');　
		return ;
	}	
	if($('#newPassword2').val()=='')
	{
		alertMsg.error('请输入新密码确认！');　
		return ;
	}	
	
	var surl = 'changePassword?usercode='+$('#username').val()+'&oldPassword='+$('#oldPassword').val()+'&newPassword1='+$('#newPassword1').val()+'&newPassword2='+$('#newPassword2').val();
	$.ajax({
        type: "post",
        contentType: "application/json",
        dataType: "json",
        timeout: 2000, //超时时间设置，单位毫秒
        url: surl,
        data: {},
        success: function(data) {
            if (data.success) {
            	alertMsg.correct(data.msg);
            	$.pdialog.closeCurrent();
            }
            else
            {
            	alertMsg.error(data.msg);
            }
        },
        complete: function(status) { //请求完成后最终执行参数
            if (status == 'timeout') { //超时,status还有success,error等值的情况
            	console.info("ajaxbuildMainMenu timeout");　　
            	 alertMsg.error('修改密码失败！');　　
            }　　           
        },
        error: function( textStatus, errorThrown) {
        	console.info("ajaxbuildMainMenu "+textStatus);　　
        	alertMsg.error('修改密码失败！ERR:'+textStatus);　　　　　
        }
    	});	
}
</script>
</div>
